<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>

<body>
    <div id='root'>
        <!-- <counter v-slot="{item}"><span>{{item}}</span></counter>
        <counter2><button>btn</button></counter2> -->
        <component :is="current"></component>
        <button @click="changecurrent">切换</button>
    </div>
    <script>
        
        
        let app = Vue.createApp({
            data() {
                return {
                    current:'counter'
                }
            },
            methods:{
                changecurrent(){
                    if(this.current == 'counter'){
                        this.current = 'counter2'
                    }else{
                        this.current = 'counter'
                    }
                }
            }
        })
        
        app.component('counter',{
            data(){return {
                list: [1,2,3]
            }},
            template:`
                <div>
                    <input />
                    <button>btn1</button>
                </div>
            `,
            methods:{
                handleClick(){
                    alert(1)
                }
            }
            
        }) 

        app.component('counter2',{
            
            template:`
                <div>
                    <input />
                    <button>btn2</button>
                </div>
            `,
            methods:{
                handleClick(){
                    alert(1)
                }
            }
            
        }) 

        let vm = app.mount('#root')
    </script>
</body>
</html>